<div class="menuRightSide">
<?php
$sessionData = SessionData::instance();

// Crossroads
html::crossroads('user');

if ($sessionData->getUserSubstitute()) {
	$url = '/user/managedPerson/cancelSubstitution';
	if ($sessionData->getAuthOrg('id') && $sessionData->getAuthOrg('id') == $sessionData->getUserSubstitute('organization_id')) {
		$url = '/org/orgPerson/cancelSubstitution';
	}
	else if ($sessionData->getAuthUser('is_admin')) {
		$url = '/admin/userSubstitution/cancelSubstitution';
	}
	echo '<div>' . html::anchor($url, text::get('userSpace-menu-cancelSubstitution'), array('title' => text::get('userSpace-cancelUserSubstitution'))) . '</div>';
}
else {
	echo '<div>' . html::anchor('/auth/logout', text::get('userSpace.menu-logout')) . '</div>';
}

$user = $sessionData->getAuthUser();
$nameAndLogin = '';
if ($sessionData->getUserSubstitute()) {
    $user = $sessionData->getUserSubstitute();
    $nameAndLogin = html::img('action/userSubstitution.png');
}
$nameAndLogin .= $user['first_name'] . '&nbsp;' . $user['last_name'];
if ($user['login']) {
	$nameAndLogin .= '&nbsp;(' .  $user['login'] . ')';
}
echo '<div>' . html::anchor('/user/myAccount/display', $nameAndLogin) . '</div>';
?>
</div>
<div id="headerBlock" class="simpleMenu">
    <?php
    foreach (UserMenu::menuList() as $labelKey => $url) {
        echo '<div';
        if ($this->activeMenuItem == $labelKey) {
            echo ' class="activeMenuTab"';
        }
        echo '>' . html::anchor($url, text::get('userSpace.menu-' . $labelKey)) . '</div>';
    }
    ?>
</div>